绘制小提琴图
bwplot(tmin.all.c)
profile_text <- read.table(text=profile, header=T, row.names=1, quote="",sep=";", check.names=F)
library(reshape2)
library(ggplot2)
data_m <- melt(profile_text)
ggplot(data = t, aes(x = month, y = tmp)) +
geom_violin() +
ylab("Temperature (˚C)") +
labs(title = "Global Monthly Mean Land Surface Temperatures From 1960-1991",
subtitle = "Excludes Antarctica")
绘制分组环境环境变量核密度图
sa_e <-data.frame(na.exclude(raster::extract(envs,xh_sa[,2:3])))
order = c(paste0("BIO",1:7), paste0("BIO",10:17),"FRS","WET","GHI","PET_ANN","MOIS","AI","GDD0","GDD5")
sa_e = sa_e[order]
View(sa_e)
op <- par(mar = rep(2, 4))
par(mfrow =c(5,5))
for(i in 1:23){
nam <- names(sa_e)
plot(density(sa_e[,i]),main=nam[i],yaxt="n",bty="L")
}
1.可视化不同物种同一因子的响应差异;
2.可视化同一物种因子的峰形;
rm(list = ls())
setwd("D:\\zhang")
localdata <- read.csv("bjpoints.csv")
tiffs <- list.files("./preasc",pattern = "asc",full.names = TRUE)
library(raster)
ascs <- stack(tiffs)
data <- extract(ascs,localdata[,-1])
data <- as.data.frame(data[,-7])
na <- colnames(data)
tt <-list()
for(i in 1:length(na)){
naa <- paste0(rep("h",6),c(1:6))
naa[i] <- as.list(round(subset(data,select =c(na[i])),digits=3))
tt <- c(tt,naa[i])
}
ss <- as.data.frame(do.call(cbind,tt))
names(ss) <- na
bjrh <- rep("bjrh",40)
data1 <- cbind(bjrh,ss)
library(ggplot2)
library(MASS)
data1$bjrh <- factor(data1$bjrh)
nclnames <- colnames(data1[,-1])
ggplot(data1,aes(x= bio10 ,fill=bjrh))
+ geom_density(alpha =0.3) + guides(fill =FALSE)+ylab("")
library(ggpubr)
ggarrange(h1,h2,h3,h4,h5,h6,h7,h8,h9,ncol=3,nrow=3,labels=c(1:9))
library(plyr)
birthwt1 <- birthwt
birthwt1$smoke <- factor(birthwt1$smoke)
birthwt1$smoke<- revalue(birthwt1$smoke,c("0"="NO smoke","1"="smoke"))
ggplot(birthwt1,aes(x=bwt,y=..density..))+
geom_histogram(binwidth = 200,fill="cornsilk",colour="grey60",size=0.2)+
geom_density()+facet_grid(smoke~.)+ ylab("")
rep1 <- c(rep("hthis",dim(hthis)[1]),rep("hgyas",dim(hgyas)[1]),
rep("hsals",dim(hsals)[1]),rep("hses",dim(hses)[1]))
alls2 <- rbind(hthis,hgyas,hsals,hses) %>% cbind(rep1,.) %>% data.frame(.)
names(alls2)[1] <- "class"
head(alls2)
alls2$class <- factor(alls2$class)
attach(alls2)
library(ggplot2)
col=c("blue","red","yellow","green")
pplo <- function(x){
ggplot(alls2,aes(x= eval(parse(text = bioss3[x])) ,fill=class))+ geom_density(alpha =0.6) +ylab("")+scale_fill_manual(values=col)+guides(fill= FALSE)+
theme(panel.border = element_blank(),panel.grid.major = element_blank(),panel.grid.minor = element_blank()) +
scale_y_continuous(breaks=NULL,expand=c(0,0))+theme(panel.grid.major=element_line(colour=NA))+
theme(axis.line.x=element_line(linetype=1,color="black",size=1))+ theme(axis.text.x = element_text(size = 10,color="black"))+
theme(axis.title.x = element_text(size=10))+xlab(nam[x])
}
ff <- lapply(1:41,pplo)
cowplot::plot_grid(plotlist = ff)